<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\file\FileInput;
use kartik\select2\Select2;
use yii\web\JsExpression;
use app\common\Functions;

/* @var $this yii\web\View */
/* @var $model \yii2mod\rbac\models\BizRuleModel */
/* @var $form ActiveForm */

$defineFieldStyle = [
    'template'      => "{label}\n<div class=\"\">{input}</div>\n{error}",
    'labelOptions' => ['class' => ' control-label']];

//楼房
$parentStyles=[];

if ($prodInstModel->parentProdName)
{

    $parentStyles['initValueText'] = $prodInstModel->parentProdName;

}

$parentStyles['options'] = ['placeholder' => '请选择 ...'];

$parentStyles['pluginOptions'] = [
    'placeholder' => '查询 ...',
    'allowClear' => true,
    'minimumInputLength' => 2,
    'language' => 'zh-CN',

    //                [
    //                'errorLoading' => new JsExpression("function () { return '稍等...'; }"),
    //            ],
    'ajax' => [
        'url' => 'seachprodinst',
        'dataType' => 'json',
        'data' => new JsExpression('function(params) { return {q:params.term,parent_prod_spec_id: ' . $parent_prod_spec_id . '}; }')
    ],
    'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
    'templateResult' => new JsExpression('function(res) {

                    return res.text; }'),



    'templateSelection' => new JsExpression('function (res) {

                            if (res.id!=res.text)
                            {
                                $("input#prodinst-parent_id").val(res.id);
                            }


                            return res.text; }')];
?>

<section class="content document-handling-resumes-form">
    <div class="box box-primary col-sm-6">
        <div class="box-body box-profile">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php echo Html::encode($this->title);?></h4>
            </div>
            <div class="row">

                 <div class="box-body">

                    <?php $form = ActiveForm::begin(); ?>

                        <?php




                        echo  $form->field($model, 'id',['labelOptions'=>['style'=>'display:none']])->hiddenInput(['value' => $model->id]);

                        echo $form->field($model, "state")->label('修改订单状态')->dropDownList($orderStates, [


                            'onchange'=>'
                            if ($(this).val()==30003)
                            {
                                $(".form-group #order-reason").show();
                            }
                            else
                            {
                                $(".form-group #order-reason").hide();
                            }
                         ',
                        ]);
                        echo $form->field($model, "reason",['labelOptions'=>['style'=>'display:none']])->label('选择作废原因')->textInput(['style'=>'display:none'])->dropDownList(Functions::getDomains('order','reason'),
                            [
                                'prompt'=>'--选择作废原因--',
                            'style'=>'display:none',
                        ]);

                        echo $form->field($model, "resumesTypeID")->label('选择处理动作')->textInput(['style'=>'display:none'])->dropDownList(Functions::getDomains('order_resumes','resumes_type_id'),
                            [
                                'prompt'=>'--选择本次的动作--',

                            ]);


//楼
                        echo $form->field($prodInstModel, 'parent_id',$defineFieldStyle)->label('带看大楼')->widget(Select2::classname(), $parentStyles);


                        echo  $form->field($model, 'remark')->label( '请务必填写跟进记录！')->textarea(['maxlength' => 256,'rows'=>4]);

                        echo  $form->field($order_resumes, 'remark')->label( '前一条记录（只读）')->textarea(['readonly' => 'true','rows'=>4]);//只读
                        ?>

                         <div class="modal-footer">

                             <?php echo Html::a(Yii::t('region', 'Cancel'), '', ['class' => 'btn btn-default','data-dismiss'=>'modal']); ?>
                             <?php echo Html::submitButton($model->getIsNewRecord() ? Yii::t('region', 'Create') : Yii::t('region', 'Update'), [
                                 'class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary', ]); ?>
                         </div>


                    <?php ActiveForm::end(); ?>

                </div>
            </div>
        </div>
    </div>
</section>
